package com.example.bank.controller;

import com.example.bank.entity.Cardinfo;
import com.example.bank.service.ICardinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-06-19
 */
@RestController
@RequestMapping("/cardinfo")
public class CardinfoController {
    @Autowired
    private ICardinfoService cardinfoService;

    // 查询所有
    @GetMapping
    public List<Cardinfo> list() {
        return cardinfoService.list();
    }

    // 根据ID查询
    @GetMapping("/{id}")
    public Cardinfo getById(@PathVariable String id) {
        return cardinfoService.getById(id);
    }

    // 新增
    @PostMapping
    public boolean save(@RequestBody Cardinfo cardinfo) {
        return cardinfoService.save(cardinfo);
    }

    // 修改
    @PutMapping
    public boolean update(@RequestBody Cardinfo cardinfo) {
        return cardinfoService.updateById(cardinfo);
    }

    // 删除
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable String id) {
        return cardinfoService.removeById(id);
    }
}
